<?php
/**
 * 公告
 */
session_start();
include "../util/DBUtil.php";
$login_type = $_SESSION['login_type'];//登录类型

//获取所有公告
$sql = "select * from tb_announcement";
$db = new DBUtil();
$result = $db->query($sql);
?>
<link rel="stylesheet" href="../css/hidden.css">
<a href="edit_announ.php?action=add" target="info" class="<?php echo $login_type!=1? 'hidden':''?>">
    <button>发布新公告</button>
</a>
<p>所有公告：</p>
<ol>
    <?php
    foreach ($result as $item){
        ?>
        <li style="padding: 3px"><a href="edit_announ.php?action=edit&id=<?php echo $item['id']?>">
                <?php echo $item['title']?><i style="margin-left: 15px;font-size: 12px">发布时间:<?php echo $item['date']?></i></a>
            <a class="<?php echo $login_type!=1? 'hidden':''?>" style="margin-left: 15px;font-size: 12px;" href="edit_announ.php?action=delete&id=<?php echo $item['id']?>" onclick="alert('是否删除?')" class="">删除</a>
        </li>
        <?php
    }
    ?>

</ol>
